log using table_A10, replace

***************** Replication of Franchino, Fabio, and Camilla Mariotto. “Bargaining Outcomes and Success in EU Economic Governance Reforms”. Political Science Research and Methods.

***************** Table A10
*   BARGAINING SUCCESS OF MEMBER STATES - t-tests
version 15

****  t-tests procedures
use t_test2_salience.dta, clear
drop actor28 success28 salience28 /* dropped because they have no values */

* renaming of variables for a more efficient command execution
local i = 28
local w = 29
while `w' <= 46 {
rename actor`w' actor`i'
rename success`w' success`i'
rename salience`w' salience`i'
local i = `i' + 1
local w = `w' + 1
}

* generation of new variables
set obs 990
gen act1=.
gen act2=.
gen A10_cell=.
gen p_value=.
gen p_value_un=.
gen c_1=.
gen c_2=.

* labels of new variables
label variable act1 "actor 1"
label variable act2 "actor 2"
label define actor 1 "Belgium" 2 "France" 3 "Germany" 4 "Italy" 5 "Luxembourg" 6 "Netherlands" 7 "Denmark" 8 "Ireland" 9 "United Kingdom" 10 "Greece" 11 "Portugal" 12 "Spain" 13 "Austria" 14 "Finland" 15 "Sweden" 16 "Cyprus" 17 "Czech Republic" 18 "Estonia" 19 "Hungary" 20 "Latvia" 21 "Lithuania" 22 "Malta" 23 "Poland" 24 "Slovakia" 25 "Slovenia" 26 "Bulgaria" 27 "Romania" 28 "European Commission" 29 "European Parliament" 30 "No eurozone states" 31 "Eurozone states" 32 "New member states" 33 "Old member states" 34 "Large member states" 35 "Medium member states" 36 "Small member states" 37 "Northern states" 38 "Southern states" 39 "Eastern states" 40 "Left leaning governments" 41 "Centre governments" 42 "Right leaning governments" 43 "Anti EU governments" 44 "Mid EU governments" 45 "Pro EU governments"
label values act1 actor
label values act2 actor
label variable p_value "paired t-test Ha: mean(diff) != 0 - two-sided p-value"
label variable p_value_un "unpaired t-test Ha: mean(diff) != 0 - two-sided p-value"
label variable c_1 "observations count act1"
label variable c_2 "observations count act2"
label variable A10_cell "color of cell in Table A10"
label define color 0 "white" 1 "light grey" 2 "grey"
label values A10_cell color

* Paired t-tests (assuming equal variance)
local i = 1
local w = 2
local r = 1

while `i' <= 44 {
while `w' <= 45 {
ttest success`i' == success`w' /* paired t-test */
replace act1=`i' in `r'
replace act2=`w' in `r'
replace p_value=r(p) in `r'  /* two-sided p-value */
count if success`i'!=. & salience`i'!=.
replace c_1=r(N) in `r'
count if success`w'!=. & salience`w'!=.
replace c_2=r(N) in `r'
local r = `r' + 1
local w = `w' + 1
}
local i = `i' + 1
local w = `i' + 1
}

* Unpaired t-tests (assuming unequal variance)
local i = 1
local w = 2
local r = 1

while `i' <= 44 {
while `w' <= 45 {
ttest success`i' == success`w', unpaired unequal /* unpaired t-test */
replace p_value_un=r(p) in `r'  /* two-sided p-value */
local r = `r' + 1
local w = `w' + 1
}
local i = `i' + 1
local w = `i' + 1
}

** A10_cell: Colours of cells in Table A10, only for governments and institutions
gen note = "Not in Table A10" if act2>29
* light grey cell if t-test assuming either equal or unequal variance is significant
replace A10_cell=1 if act2<30 & (p_value<0.05 | p_value_un<0.05)
* grey cell if both t-tests assuming equal and unequal variance are significant
replace A10_cell=2 if act2<30 & p_value<0.05 & p_value_un<0.05

count if A10_cell==1 & act2<30 /*count of 21 light grey cells of Table A10 */
count if A10_cell==2 & act2<30 /*count of 16 grey cells of Table A10 */

* Additional significant t-test results (unequal variance) for groups of governments
sort act1 act2
list act1 act2 p_value_un if note=="Not in Table A10" & p_value_un<0.05

log close
